(async () => {
    try {
        const { processRushTimeoutBatch, processOrderExpireBatch } =
            require('../service/order_monitor_service');

        await processOrderExpireBatch();
        await processRushTimeoutBatch();

        console.log('[order_monitor] done');
    } catch (err) {
        console.error('[order_monitor] failed:', err);
        process.exitCode = 1;
    } finally {
        //可选：如果脚本里持有连接，记得在这儿关闭，避免进程悬挂
        const { sequelize } = require('../config/mysql_config');
        const { redis } = require('../config/redis_client');
        await Promise.allSettled([
          sequelize?.close?.(),
          redis?.quit?.()
        ]);
    }
})();